import '../styles/styles.scss';
import '../styles/headings.css';

import {HttpClientModule} from '@angular/common/http';
import {enableProdMode, NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {ConnectionBackend, Http, HttpModule, RequestOptions, XHRBackend} from '@angular/http';
import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {PreloadAllModules, RouterModule} from '@angular/router';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
import {NgxPaginationModule} from 'ngx-pagination';
/*
 * Platform and Environment providers/directives/pipes
 */
import {environment} from 'environments/environment';

// App is our top level component
import {AppComponent} from './app.component';
import {HomeComponent} from './pages/home/home.component';
import {SurveyListComponent} from './pages/surveylist/surveylist.component';
import {APP_RESOLVER_PROVIDERS} from './app.resolver';
import {ROUTES} from './app.routes';
import {AppState, InternalStateType} from './app.service';
import {AppFooterComponent} from './components/appfooter/appfooter.component';
import {AppHeaderComponent} from './components/appheader/appheader.component';
import {SurveySummaryComponent} from './components/survey-summary-list/survey-summary-list.component';
import {SurveyService} from './services/survey.service';

// Application wide providers
const APP_PROVIDERS = [...APP_RESOLVER_PROVIDERS, AppState];

type StoreType = {
  state: InternalStateType,
  restoreInputValues: () => void,
  disposeOldHosts: () => void
};

/**
 * `AppModule` is the main entry point into Angular2's bootstraping process
 */
@NgModule({
  bootstrap: [AppComponent],
  declarations: [AppComponent, HomeComponent, SurveyListComponent, AppHeaderComponent, AppFooterComponent, SurveySummaryComponent],
  /**
   * Import Angular's modules.
   */
  imports: [
    NgbModule.forRoot(),
    BrowserModule,
    BrowserAnimationsModule,
    FormsModule,
    HttpModule,
    HttpClientModule,
    NgxPaginationModule,
    RouterModule.forRoot(
        ROUTES,
        {useHash: Boolean(history.pushState) === false, preloadingStrategy: PreloadAllModules}),
  ],
  /**
   * Expose our Services and Providers into Angular's dependency injection.
   */
  providers: [environment.ENV_PROVIDERS, APP_PROVIDERS, SurveyService]
})
export class AppModule {}
